package com.example.book.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@TableName("book")
@Data
public class Book implements Comparable<Book>{

    @TableId (type = IdType.AUTO)
    private Integer id;
    private String isbn;

    public String name;
    private BigDecimal price;
    private String author;
    private Integer borrownum;
    private String publisher;
    @JsonFormat(locale="zh",timezone="GMT+8", pattern="yyyy-MM-dd")
    private Date createTime;
    private String status;

    public int score;
    public Book(String name, int score) {
        this.name = name;
        this.score = score;
    }
    @Override
    public String toString() {
        return "book{" + "bookname:'" + name + '\'' +".score:" + score +'}';
    }

    @Override
    public int compareTo(Book o) {
        //图书进行分数评比
        return score > o.score ? -1 : 1;
    }
}
